package iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author shenhan
 * @create 2020/4/10 16:31
 * @description
 */
public class OutputImpl {
    List<College> colleges;

    public OutputImpl(List<College> colleges) {
        this.colleges = colleges;
    }

    public void printCollege() {
        final Iterator<College> iterator = colleges.iterator();
        while (iterator.hasNext()) {
            final College college = iterator.next();
            System.out.println(college.getName());
            printDepartment(college.createIterator());
        }
    }

    public void printDepartment(Iterator iterator) {
        while (iterator.hasNext()) {
            final Department next = (Department) iterator.next();
            System.out.println(next.getName());
        }
    }
}
